package genericdemo;


import java.util.*;

public class GenericsDemo {
    static List<Dog> dogs = new ArrayList<>();

    public static void printAllDogs() {
        List list = dogs;
        list.add(""); //Type erasure!!!!

        for(Dog element : dogs) {
            System.out.println(element.gavGav());
        }

        Collections.sort(dogs, new Comparator<Dog>() {
            @Override
            public int compare(Dog o1, Dog o2) {
                o1.gavGav();
                return 0;
            }
        });
    }

    public static void main(String[] args) {
        dogs.add(new Dog());
        Dog dog = dogs.get(0);

        MySuperSorted.<String,String>sort();

    }
}

class MySuperSorted<K,V> {
    K field;

    public V paramsSort(K key) {
        return null;
    }

    public static <T extends Comparable, P> T sort() {
        //.......
        //.......
        List<T> list;

        return null;
    }
}



class TypedBlockingQueue { //DogblockigQueue
    private List<Dog> queue;

    public Dog get() { return null; }
    public void add(Dog dog) {}
}

class GeneralBlockingQueue { //REUSE for sync algorithms
    private List queue;

    public Object get() { return null; }
    public void add(Object dog) { queue.add(new Dog()); }
}

class GenericBlockingQueue<T> { //Strongly typed system
    private List<T> queue;

    public T get() { return null; }
    public void add(T element) { queue.add(element); }
}

class AbstractComparator<T> implements Comparator<T> {
    @Override
    public int compare(T o1, T o2) {
        return 0;
    }
}
class DogComparator implements Comparator<Dog> {
    @Override
    public int compare(Dog o1, Dog o2) {
        return 0;
    }
}













